package org.example.controller;

import dev.langchain4j.service.MemoryId;
import dev.langchain4j.service.SystemMessage;
import org.example.mapper.MessagesMapper;
import org.example.pojo.Messages;
import org.example.service.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.List;

@RestController
public class ChatController 
{
	@Autowired
	private ConsultantService consultantService;

//	@GetMapping(value = "chat",produces = "text/html;charset=utf-8")	//produces设置字符集
////	@GetMapping(value = "chat")
//	public Flux<String> chat(@RequestParam String mes)
//	{
//		Flux<String> chat = consultantService.chat(mes);
//		return chat;
//	}

	@GetMapping(value = "chat",produces = "text/html;charset=utf-8")	//produces设置字符集
	public Flux<String> chat(@RequestParam String memoryId,@RequestParam String mes)
	{
		Flux<String> chat = consultantService.chat(memoryId,mes);
		return chat;
	}
	
	@Autowired
	MessagesMapper messagesMapper;

	@GetMapping("get")
	public void get()
	{
		List<Messages> messages = messagesMapper.selectList(null);
		System.out.println(messages);
	}
	
}